home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 4 / Amiga Tools 4.iso / tools / netzwerk / parnet / sources / defs.h next >
C/C++ Source or Header  |  1996-02-26  |  4KB  |  156 lines

  1.  
  2. /*
  3.  *  DEFS.H
  4.  *
  5.  *  ---- NOTE, ONLY IOREQUEST STRUCTURE IS PUBLIC, ALL OTHER STRUCTURES
  6.  *     **WILL** CHANGE WITHOUT NOTICE ----
  7.  */
  8.  
  9. #define PARNET_SRC
  10.  
  11. #include <exec/types.h>
  12. #include <devices/trackdisk.h>
  13. #include <devices/timer.h>
  14. #include <hardware/intbits.h>
  15. #include <exec/errors.h>
  16. #include <exec/interrupts.h>
  17. #include <dos/dos.h>
  18. #include <clib/exec_protos.h>
  19. #include <clib/alib_protos.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23.  
  24. #include <pragmas/exec_pragmas.h>
  25.  
  26. #define PORTNAME    "parnet.cfg"
  27.  
  28. #define MAXPKTSIZE  (8192+256)
  29.  
  30. #define IOF_QUEUED  0x02
  31. #define IOF_RUN     0x04
  32.  
  33. #define STRM_RESERVE    0x8000        /*    ports reserved for stream protocol */
  34. #define STRM_PORTS    512        /*    must be factor of 32           */
  35.  
  36. typedef unsigned char    ubyte;
  37. typedef unsigned short    uword;
  38. typedef unsigned long    ulong;
  39.  
  40. typedef struct Library    LIB;
  41. typedef struct MsgPort    PORT;
  42. typedef struct List    LIST;
  43. typedef struct Node    NODE;
  44. typedef struct MinNode    MNODE;
  45. typedef struct Task    Task;
  46. typedef struct Message    Message;
  47.  
  48. typedef struct timerequest IOT;
  49.  
  50. typedef long (*func_ptr)();
  51. typedef void (*func_void)();
  52. struct Packet;
  53. struct IOParReq;
  54. typedef struct IOParReq    Iob;
  55.  
  56. typedef struct {
  57.     LIB     Lib;        /*    library node        */
  58.     ubyte   ParAddress;     /*    1-255            */
  59.     PORT    Port;        /*    task port        */
  60.     long    PLock[2];        /*    task lock        */
  61.     LIST    UnitList;        /*    active units (ports)    */
  62. } Device;
  63.  
  64. /*
  65.  *  Unit Core Structure (not user accessable) (do not access!)
  66.  */
  67.  
  68. typedef struct {
  69.     NODE    Node;        /*    link node   DO NOT MOVE */
  70.                 /*    begin I/O   DO NOT MOVE */
  71.     void    (*BeginIO)(Iob *);
  72.                 /*    abort I/O   DO NOT MOVE */
  73.     void    (*AbortIO)(Iob *);
  74.     void    (*CloseFunc)(Iob *);
  75.                 /*    low level packet data    */
  76.     void    (*DataFunc)(int, struct Packet *, long);
  77.     uword   RefCnt;
  78.     uword   Port;        /*    core port ident     */
  79.     uword   Protocol;        /*    protocol id        */
  80.     ulong   DestAddr;        /*    destination  0 = self    */
  81.     uword   Flags;        /*    status flags        */
  82.     uword   State;        /*    (protocol private)      */
  83.     long    UnitLock[2];
  84.     LIST    PendIOR;        /*    pending read requests        */
  85.     LIST    PendIOW;        /*    pending write requests        */
  86.     LIST    PendCon;        /*    pending connect requests    */
  87.     LIST    PendLsn;        /*    pending listen requests     */
  88. } Unit;
  89.  
  90. /*
  91.  *  Io request structure and user defines
  92.  */
  93.  
  94. #include "devices/parnet.h"
  95.  
  96. /*
  97.  *  A low level network packet
  98.  */
  99.  
  100. typedef struct Packet {
  101.     Message Msg;
  102.     Iob     *iob;            /*    IO req (unit_str)       */
  103.     Unit    *io_Unit;            /*    unit involved        */
  104.     ubyte   DestAddr;            /*    Destination machine    */
  105.     ubyte   Reserved;
  106.     uword   DestPort;            /*    Destination port no.    */
  107.     ulong   DLen1;            /*    Data Length        */
  108.     ulong   DLen2;            /*    Data Length        */
  109.     ubyte   *Data1;            /*    Data Pointer (lw algn)  */
  110.     ubyte   *Data2;            /*    Data Pointer (lw algn)  */
  111. } Packet;
  112.  
  113. /*
  114.  *  private public port to remember addr across closes.
  115.  */
  116.  
  117. typedef struct {
  118.     PORT    Port;
  119.     long    Address;
  120.     long    Timeout;
  121.     char    DebugBuf[32];
  122. } PubPort;
  123.  
  124. /*
  125.  *  Globals
  126.  */
  127.  
  128. extern long    ParLLTimeout;        /*    par.asm */
  129. extern Device    *DevBase;
  130. extern PubPort    *StickyPort;
  131.  
  132. /* parnet.c */
  133. extern Unit    *FindUnitForPort(uword);
  134. extern Unit    *AllocUnit(Iob *, func_void, func_void, func_void,func_void);
  135. void        FreeUnit(Unit *);
  136. extern Packet    *AllocParPacket(Iob *, Unit *, ubyte *, long, ubyte *, long);
  137. void        FreeParPacket(Packet *);
  138. extern void    ReadConfig(void);
  139. extern void    WriteConfig(void);
  140.  
  141. /* lock.asm */
  142. extern void    LockAddr(long *);
  143. extern void    UnlockAddr(long *);
  144. extern int    TryLockAddr(long *);
  145.  
  146. /* par.asm */
  147. extern void    ParAddress(int);                        /*  par.asm     */
  148. extern void    Time10000(void);                        /*  par.asm     */
  149.  
  150. /* task.c */
  151. extern void    ParNetTask(void);                       /*  task.c      */
  152. void        QueuePacketForWrite(Packet *);
  153.  
  154. /* unit_ctl.c */
  155. void        CtlBeginIO(Iob *);
  156.